package com.holyant.goods.dto;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.constant.RegexpConstants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;
import java.util.List;

/**
 * 商品信息dto
 * 
 * @author tswsoft
 * @date 2021-04-01
 */
@ApiModel("商品保存信息Dto")
@Data
public class GdsGoodsSaveDto {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "商品id")
    private Long id;

    @ApiModelProperty(value = "商品编码")
    private String code;

    /** 商品条形码 */
    @Excel(name = "商品条形码")
    @ApiModelProperty(value = "商品条形码")
    private String barcode;

    @ApiModelProperty(value = "商品名称")
    private String name;
    private String eName;

    /** 所属分类id */
    @ApiModelProperty(value = "所属分类id")
    private Long categoryId;

    @ApiModelProperty(value = "所属分类名称")
    private String categoryName;

    /** 税率分类id */
    @ApiModelProperty(value = "税率分类id")
    private Long taxCategoryId;

    /** 税率分类编码 */
    @ApiModelProperty(value = "税率分类编码")
    private String taxCategoryCode;

    /** 税率分类名称 */
    @ApiModelProperty(value = "税率分类名称")
    private String taxCategoryBane;

    /** 品牌id */
    @ApiModelProperty(value = "品牌id")
    private Long brandId;

    /** 品牌名称 */
    @ApiModelProperty(value = "品牌名称")
    private String brandName;


    /** 经营类目ID */
    @ApiModelProperty(value = "经营类目ID")
    @NotNull(message = "经营类目不能为空")
    private Long busCategoryId;

    /** 经营类目名称 */
    @ApiModelProperty(value = "经营类目名称")
    @NotEmpty(message = "经营类目不能为空")
    private String busCategoryName;


    @ApiModelProperty(value = "品牌系列")
    private String catena;

    /** 毛重 */
    @ApiModelProperty(value = "毛重")
    private BigDecimal grossWeight;

    /** 净重 */
    @ApiModelProperty(value = "净重")
    private BigDecimal netWeight;

    /** 体积 */
    @ApiModelProperty(value = "体积")
    private BigDecimal volume;

    /** 长*/
    private BigDecimal volumeLong;
    /** 宽*/
    private BigDecimal volumeWide;
    /** 高*/
    private BigDecimal volumeHigh;

    /**
     * 箱规
     */
    @Excel(name = "箱规")
    @ApiModelProperty(value = "箱规")
    private String boxSpec;

    /**
     * 托规
     */
    @Excel(name = "托规")
    @ApiModelProperty(value = "托规")
    private String palletSpec;

    /** 发货方式 10-保税区发货 20-香港直邮 30-海外直邮 100-国内发货 */
    @ApiModelProperty(value = "发货方式 10-保税区发货 20-香港直邮 30-海外直邮 100-国内发货")
    private Integer deliveryType;
    /**
     * 规格单位
     */
    @ApiModelProperty(value = "规格单位")
    private Integer specsUnit;

    /** 默认供应商id */
    @ApiModelProperty(value = "默认供应商id")
    private Long supplierId;

    /** 默认供应商 */
    @ApiModelProperty(value = "默认供应商")
    private String supplierName;

    /** 原产国 */
    @ApiModelProperty(value = "原产国")
    private String originCountry;

    /** 采购价 */
    @ApiModelProperty(value = "采购价")
    private BigDecimal purPrc;

    /** 销售价 */
    @ApiModelProperty(value = "销售价")
    private BigDecimal salesPrc;

    /** 规格 */
    @ApiModelProperty(value = "规格")
    private String specs;


    /** 规格数量 */
    @NotNull(message = "商品规格数量不能为空!")
    @Min(value = 1,message = "商品规格数量只能为大于0的正整数")
    @ApiModelProperty(value = "规格数量")
    private Integer specsQty;

    /** 规格数量字符串 */
    @Pattern(message = "商品规格数量只能为大于0的正整数！",regexp = RegexpConstants.POSITIVE_INTEGER)
    @ApiModelProperty(value = "规格数量")
    private String specsQtyStr;




    /** 计量单位id */
    @ApiModelProperty(value = "计量单位id")
    private Long unitId;

    /** 计量单位名称 */
    @ApiModelProperty(value = "计量单位名称")
    private String unitName;

    /** HsCode */
    @ApiModelProperty(value = "HsCode")
    private String hsCode;

    /** 行邮税 */
    @ApiModelProperty(value = "行邮税")
    private String postTaxCode;

    @ApiModelProperty(value = "保质期")
    private Integer qualityPeriod;

    /** 扩展属性 */
    @ApiModelProperty(value = "扩展属性")
    private String extAttr;

    @ApiModelProperty(value = "仓库id")
    private Long warehouseId;

    @ApiModelProperty(value = "仓库名称")
    private String warehouseName;

    /** 商品所属分类sku属性结构 */
    @ApiModelProperty(value = "商品所属分类sku属性结构")
    private String categorySkuAttr;

    /** 备注 */
    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "主图")
    private String imgUrl;

//    @ApiModelProperty(value = "图片列表")
//    private List<BaseFileDto> images;

    @ApiModelProperty(value = "商品sku信息列表")
    private List<GdsSkuSaveDto> gdsSkuSaveDtoList;

    @ApiModelProperty(value = "流水号")
    private Integer serialNum;

    @ApiModelProperty(value = "跨境还是国贸 10跨境订单，20国贸订单")
    private Integer customsType;

    /** 商品辅助单位属性结构*/
    private String assistUnitAttr;

    private List<AssistUnit> assistUnitList;

    public void setAssistUnitList(List<AssistUnit> assistUnitList){
        this.assistUnitList = assistUnitList;
        this.assistUnitAttr = JSON.toJSONString(assistUnitList);
    }

    @Data
    public static class AssistUnit{
        /**
         * 单位编码
         */
        private String unitCode;
        /**
         * 单位名称
         */
        private String unitName;
        /**
         * 当前数量
         */
        private Integer curQty;
        /**
         * 换算数量
         */
        private Integer castQty;

        /**
         * 最小单位
         */
        private Integer minUnit;
    }

}
